#!/usr/bin/sh
# Copyright 2011-2023, Mageia
# Modified 2024, Funda Wang <fundawang@yeah.net>
# Licensed under GPL-2.0-or-later

CONFIGURE_TOP="${1:-.}"
if [ -e $CONFIGURE_TOP/configure ] && grep -q -F '$deplibs $compiler_flags' $CONFIGURE_TOP/configure; then
  echo "Fixing libtool inside configure to pass -Wl,xxx options earliest"

  sed -i \
   -e 's,$libobjs $deplibs $compiler_flags,$compiler_flags $libobjs $deplibs,' \
   -e 's,$predep_objects $libobjs $deplibs $postdep_objects $compiler_flags,$compiler_flags $predep_objects $libobjs $deplibs $postdep_objects,' \
   $CONFIGURE_TOP/configure
fi

